import axios from '../../libs/request'
import { getToken } from '../../libs/tools'
/**
 * 获取指定论文的PDF文件
 * @param { string } id 论文ID 
 */
export const getPdf = id => axios.request({
  url: '/api/v1/admin/paper/pdf/' + id,
  method: 'get'
})

/**
 * 删除指定论文的PDF文件
 * @param { string } id 论文ID 
 */
export const deletePdf = id => axios.request({
  url: '/api/v1/admin/paper/pdf/' + id,
  method: 'delete'
})

/**
 * 分页获取所有PDF文件
 * @param {*} pageIndex 
 * @param {*} pageSize 
 */
export const getAll = (pageIndex, pageSize = 10) => axios.request({
  url: '/api/v1/admin/paper/pdf',
  method: 'get',
  params: {
    from: pageIndex,
    size: pageSize
  }
})

/**
 * 上传PDF文件
 */
export const uploadUrl = '/api/v1/admin/paper/pdf'
export const upload = (pdf) => axios.request({
  url: uploadUrl,
  method: 'post',
  headers: {
    'Content-Type': 'multipart/form-data',
    Authorization: 'Bearer ' + getToken()
  },
  data: pdf
})
